import Service from './$axios'
// import Service from './$axios2'
import { authPrefix2, authPrefix } from '../config'
//登录
export const login = (name, password) => {
    return Service({
        url: `${authPrefix}/login?account=` + name + `&password=` + password,
        method: `post`
    })
}

//登出
export const loginOut = () => {
    return Service({
        url: `${authPrefix}/logout`,
        method: `post`
    })
}
//根据id获取用户
export const queryUserById = (id) => {
    return Service({
        url: `${authPrefix2}/user/queryUserById?userId=` + id,
        method: `get`
    })
}
//获取菜单
export const getMenus = (str) => {
    return Service({
        url: `${authPrefix2}/menu/queryTreeMenu?type=` + str,
        method: `get`,
    })
}
//添加 修改 菜单
export const addMenu = (data) => {
    return Service({
        url: `${authPrefix2}/menu/addMenu`,
        method: `post`,
        data: data,
    })
}

//删除菜单
export const deleteMenu = (id) => {
    return Service({
        url: `${authPrefix2}/menu/deleteMenu/` + id,
        method: `delete`
    })
}

//根据id获取菜单
export const getMenuById = (id) => {
    return Service({
        url: `${authPrefix2}/menu/queryMenuParentById/` + id,
        method: `get`
    })
}

//新增 修改 按钮
export const addOrUpdateBtn = (data) => {
    return Service({
        url: `${authPrefix2}/button/addButton`,
        method: `post`,
        data: data
    })
}

//根据菜单id查询按钮
export const getBtnByMenuId = (id) => {
    return Service({
        url: `${authPrefix2}/button/queryButton/` + id,
        method: `get`
    })
}
//删除按钮
export const deleteBtnById = (id) => {
    return Service({
        url: `${authPrefix2}/button/deleteButton/` + id,
        method: `delete`
    })
}
//修改密码
export const updatePss = (data) => {

    return Service({
        url: `${authPrefix2}/user/updatePss`,
        method: `post`,
        data: data,
    })
}

//获取部门
export const getDepartMents = () => {
    return Service({
        url: `${authPrefix2}/department/queryTreeDepartment`,
        method: `get`,
    })
}

//添加 修改 部门
export const addDepartMent = (data) => {
    return Service({
        url: `${authPrefix2}/department/addDepartment`,
        method: `post`,
        data: data,
    })
}

//删除部门
export const deleteDepartMent = (id) => {
    return Service({
        url: `${authPrefix2}/department/deleteDepartment/` + id,
        method: `delete`
    })
}

//获取角色
export const getRoles = () => {
    return Service({
        url: `${authPrefix2}/role/queryPageRole?pageNum=1&pageSize=9999`,
        method: `get`,
    })
}

//添加 修改 部门
export const addOrUpdateRole = (data) => {
    return Service({
        url: `${authPrefix2}/role/addRole`,
        method: `post`,
        data: data,
    })
}

//删除角色
export const deleteRole = (id) => {
    return Service({
        url: `${authPrefix2}/role/deleteRole/` + id,
        method: `delete`
    })
}



//根据角色id查询拥有权限
export const queryRoleMenuList = (id, type) => {
    return Service({
        url: `${authPrefix2}/role/queryRoleMenuList?roleId=` + id + `&type=` + type,
        method: `get`
    })
}
//权限配置
export const authorityDeploy = (data) => {
    return Service({
        url: `${authPrefix2}/role/authorityDeploy`,
        method: `post`,
        data: data,
    })
}

//查询所有用户
export const getUsers = (str) => {
    return Service({
        url: `${authPrefix2}/user/queryPageUser?` + str,
        method: `get`,
    })
}

//添加 修改 用户
export const addOrUpdateUser = (data) => {
    return Service({
        url: `${authPrefix2}/user/addUser`,
        method: `post`,
        data: data,
    })
}

//角色分配
export const roleAssignment = (data) => {
    return Service({
        url: `${authPrefix2}/user/roleAssignment`,
        method: `post`,
        data: data,
    })
}

//删除用户
export const deleteUser = (id) => {
    return Service({
        url: `${authPrefix2}/user/deleteUser/` + id,
        method: `delete`
    })
}
//重置用户密码
export const resetPassword = (id) => {
    return Service({
        url: `${authPrefix2}/user/resetPss/` + id,
        method: `get`
    })
}
// 新增角色返回数据
export const returnRole = () => {
    return Service({
        url: `${authPrefix2}/role/returnRole`,
        method: `get`
    })
}


// //得到日志类型
// export const getLogTypes = () => {
//     return Service({
//         url: `/i3adc-log/log/queryLogType`,
//         method: `get`
//     })
// }

// //查询所有日志
// export const getLogs = (str) => {
//     return Service({
//         url: `/i3adc-log/log/queryPageLog?`+str,
//         method: `get`,
//     })
// }




